<template>
  <view>
    <view class="hrader">
      <image
        src="../../../static/bback.png"
        class="goback"
        @click="gobackClick"
        mode=""
      />
      查看物流
    </view>
    <view class="content">
      <view class="sec1">
        <view class="title">订单信息</view>
        <view class="box">
          <image class="img" :src="detail.image" mode="" />
          <view class="mess">
            <text class="fbt">订 单 号：{{ detail.order_sn }} </text>
            <text class="fbt"
              >创建时间：{{ detail.add_time | formatDate }}
            </text>
            <text class="fbt"
              >付款时间：{{ detail.payment_time | formatDate }}
            </text>
          </view>
        </view>
      </view>
      <view class="sec2">
        <view class="kddh">
          快递：
          <text style="margin-right: 5rpx">{{ expressCode }}</text>
          <text>{{ shippingCode }}</text>
        </view>
        <view class="wrap">
          <view class="lists">
            <view class="li" v-for="(item, i) in list" :key="i">
              <view>{{ item.time }}</view>
              <view>{{ item.context }}</view>
            </view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      order_sn: "",
      detail: "",
      list: [],
      expressCode: "", // 快递公司
      shippingCode: "", // 快递单号
      express_code: "", // 快递单号
    };
  },
  onLoad(e) {
    this.order_sn = e.order_sn;
    this.orderDetail(this.order_sn);
  },
  methods: {
    gobackClick() {
      uni.navigateBack({
        delta: 1,
      });
    },
    // 获取订单详情
    async orderDetail(id) {
      const res = await this.$myRequest({
        url: "order/orderDetail",
        method: "POST",
        data: {
          order_sn: id,
        },
      });
      if (res.data.code == 1) {
        this.detail = res.data.data;
        uni.setStorage({
          key: "detail",
          data: this.detail,
        });
        this.expressCode = this.detail.orderCommon.express_name;
        this.express_code = this.detail.orderCommon.express_code;
        this.shippingCode = this.detail.orderCommon.shipping_code;
        if (this.shippingCode) {
          this.getExpress();
        }
      }
    },
    // 获取快递信息
    async getExpress() {
      const res = await this.$myRequest({
        url: "order/getExpress",
        method: "POST",
        data: {
          expressCode: this.express_code,
          shippingCode: this.shippingCode,
        },
      });
      if (res.data.code == 1) {
        this.list = res.data.data.reverse();
      } else {
        uni.showToast({
          icon: "none",
          title: res.data.msg,
        });
      }
    },
  },
};
</script>

<style lang="scss">
page {
  background: #f4f4f4;
  min-height: 100vh;
  position: relative;
}
.hrader {
  width: 100%;
  height: 88rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  position: relative;
  font-size: 36rpx;
  font-weight: 500;
  color: #333333;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 99;
  .goback {
    position: absolute;
    width: 22rpx;
    height: 34rpx;
    left: 28rpx;
  }
}
.content {
  padding-top: 110rpx;
  overflow: hidden;
  .sec1 {
    width: 100%;
    min-height: 200rpx;
    background: #fff;
    box-sizing: border-box;
    padding: 30rpx;
    .title {
      font-size: 30rpx;
      font-weight: 550;
      color: #373737;
      box-sizing: border-box;
      padding-bottom: 22rpx;
      padding-left: 21rpx;
      border-bottom: 1rpx solid #eee;
      position: relative;
    }
    .title::before {
      position: absolute;
      content: "";
      width: 6rpx;
      height: 30rpx;
      background: #c52b2e;
      border-radius: 3rpx;
      left: 0;
      top: 50%;
      transform: translateY(-84%);
    }
    .box {
      display: flex;
      padding: 30rpx 0 0;
      .img {
        display: block;
        width: 160rpx;
        height: 160rpx;
        object-fit: cover;
        margin-right: 30rpx;
        border-radius: 10rpx;
      }
      .rig {
        width: 70%;
        position: relative;
        > view:nth-child(1) {
          width: 100%;
          font-size: 30rpx;
          color: #333333;
          font-weight: bold;
          display: flex;
          align-items: center;
          justify-content: space-between;
          text:nth-child(1) {
            width: 80%;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
            word-break: break-all;
          }
          text:nth-child(2) {
            font-size: 26rpx;
            color: #333333;
            font-weight: normal;
          }
        }
        > view:nth-child(2) {
          position: absolute;
          right: 0;
          bottom: 0;
          left: 0;
          display: flex;
          align-items: center;
          justify-content: space-between;
          text {
            display: block;
            font-size: 26rpx;
            color: #666666;
          }
          text:nth-child(2) {
            color: #333333;
          }
        }
      }
    }
    .mess {
      .bt {
        display: block;
        font-size: 28rpx;
        font-weight: 400;
        color: #333333;
      }
      .fbt {
        display: block;
        margin-top: 15rpx;
        font-size: 28rpx;
        font-weight: 400;
        color: #333333;
      }
    }
  }
  .sec2 {
    width: 100%;
    box-sizing: border-box;
    margin-top: 20rpx;
    .kddh {
      box-sizing: border-box;
      padding: 30rpx 30rpx;
      font-size: 28rpx;
      color: #373737;
      background: #fff;
      padding-left: 50rpx;
    }
    .wrap {
      width: 100%;
      overflow: hidden;
      background: #fff;
      box-sizing: border-box;
      padding: 25rpx;
      padding-left: 65rpx;
      .lists {
        border-left: 1px solid #eee;
      }
      .li {
        box-sizing: border-box;
        padding-left: 50rpx;
        position: relative;
        margin-bottom: 50rpx;
        view {
          display: block;
          width: 100%;
          font-size: 24rpx;
          color: #939393;
        }
        view:nth-child(1) {
          margin-bottom: 15rpx;
        }
      }
      .li::before {
        position: absolute;
        content: "";
        width: 10rpx;
        height: 10rpx;
        background: #939393;
        border-radius: 50%;
        left: -6rpx;
        top: 50%;
        transform: translateY(-50%);
      }
    }
  }
}
</style>
